home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Visual Cafe Pro v1.0 / VISCAFE.BIN / MovingAnimation.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-06-19  |  1.9 KB  |  83 lines

  1. package symantec.itools.multimedia;
  2.  
  3. import java.awt.Component;
  4. import java.awt.Dimension;
  5. import java.awt.Graphics;
  6. import java.awt.Image;
  7.  
  8. public class MovingAnimation extends Animator implements Runnable {
  9.    int loopslot = 0;
  10.    int shiftOffset = 10;
  11.    private int curOffset = 0;
  12.  
  13.    public MovingAnimation() {
  14.       super.forever = true;
  15.    }
  16.  
  17.    public void setShiftOffset(int var1) {
  18.       this.shiftOffset = var1;
  19.    }
  20.  
  21.    public int getShiftOffset() {
  22.       return this.shiftOffset;
  23.    }
  24.  
  25.    public void run() {
  26.       Thread.currentThread().setPriority(4);
  27.       Dimension var1 = ((Component)this).size();
  28.       int var2 = super.images.size();
  29.       if (var2 > 1) {
  30.          if (this.shiftOffset < 0) {
  31.             this.curOffset = var1.width - super.maxWidth;
  32.          }
  33.  
  34.          int var3 = 0;
  35.  
  36.          while(true) {
  37.             var1 = ((Component)this).size();
  38.             if (++this.loopslot >= var2) {
  39.                ++var3;
  40.                if (var3 > super.numLoops && !super.forever) {
  41.                   break;
  42.                }
  43.  
  44.                this.loopslot = 0;
  45.                this.curOffset += this.shiftOffset;
  46.                if (this.curOffset < 0) {
  47.                   this.curOffset = var1.width - super.maxWidth;
  48.                } else if (this.curOffset + super.maxWidth > var1.width) {
  49.                   this.curOffset = 0;
  50.                }
  51.             }
  52.  
  53.             ((Component)this).repaint();
  54.  
  55.             try {
  56.                Thread.sleep((long)super.delay);
  57.             } catch (InterruptedException var4) {
  58.                return;
  59.             }
  60.          }
  61.       }
  62.  
  63.    }
  64.  
  65.    public boolean imageUpdate(Image var1, int var2, int var3, int var4, int var5, int var6) {
  66.       if ((var2 & 56) != 0 && super.images != null && this.loopslot < super.images.size() && ((AnimatorImage)super.images.elementAt(this.loopslot)).image == var1) {
  67.          ((Component)this).repaint(100L);
  68.       }
  69.  
  70.       return (var2 & 96) == 0;
  71.    }
  72.  
  73.    public void paint(Graphics var1) {
  74.       if (super.images != null && this.loopslot < super.images.size()) {
  75.          Image var2 = ((AnimatorImage)super.images.elementAt(this.loopslot)).image;
  76.          if (var2 != null) {
  77.             var1.drawImage(var2, this.curOffset, 0, this);
  78.          }
  79.       }
  80.  
  81.    }
  82. }
  83.